extends PanelContainer

@onready var 开始界面: Control = $".."
@onready var 淡入淡出动画节点: AnimationPlayer = $"../淡入淡出动画节点"
@onready var 设置选项栏: Control = $"../设置选项栏"


@export var 当前选项栏:String
@export var 选项栏列表:Array[String] =["默认选项栏","设置选项栏"]


func 选项栏初始化():
	for i in self.get_children():
		i.visible = false
	var 默认选项栏 = self.find_child("默认选项栏")
	if 默认选项栏 != null:
		默认选项栏.visible = true
	选项栏淡入动画()


func 切换选项栏(下个选项栏):
	当前选项栏 = 下个选项栏
	选项栏淡出动画()


func 更新可见选项栏():
	for i in self.get_children():
		i.visible = false
	if 当前选项栏 in 选项栏列表:
		self.find_child(当前选项栏).visible = true


func 选项栏淡出动画():
	淡入淡出动画节点.play("淡出")


func 选项栏淡入动画():
	淡入淡出动画节点.play("淡入")



func _on_淡入淡出动画节点_animation_finished(anim_name: StringName) -> void:
	match anim_name:
		"淡出":
			更新可见选项栏()
			选项栏淡入动画()
		"淡入":
			pass
